package com.amigo.online.provider.user.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.amigo.online.common.base.controller.BaseController;
import com.amigo.online.common.core.response.Response;
import com.amigo.online.common.param.dto.user.UserHobbyDto;
import com.amigo.online.provider.user.model.entity.Hobby;
import com.amigo.online.provider.user.service.HobbyService;

@RestController
@RequestMapping(value = "/hobby", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class HobbyController extends BaseController {

    @Autowired
    private HobbyService hobbyService;

    @PostMapping("/updateHobby")
    public ResponseEntity<Response> updateUserHobby(@RequestBody UserHobbyDto dto) {
        return success(hobbyService.updateHobby(dto.getHobbyList(), dto.getType()));
    }

    @GetMapping("/{type}")
    public ResponseEntity<Response> getHobby(@PathVariable("type") Integer type) {
        List<Hobby> hobby = hobbyService.findHobby(type);
        return success(hobby);
    }

}
 